/**
 * Created by DELL on 2016/8/8.
 */
var buildTable = {
    init:function (tableId,caption,heading) {

        var oTable = document.getElementById(tableId);
        var oCaption = document.createElement('caption');
        var textNode = document.createTextNode(caption);
        oCaption.appendChild(textNode);
        oTable.appendChild(oCaption);
        var oTr = document.createElement("tr");

        for(var i in heading){
            var oTh = document.createElement("th");
            var oTxt = document.createTextNode(i);
            oTh.width = heading[i];
            oTh.appendChild(oTxt);
            oTr.appendChild(oTh);
        }
     oTable.appendChild(oTr);
        return oTable;
    },
    addTr:function (tableId,data) {
        var oTable = document.getElementById(tableId);

        var oTr = document.createElement("tr");

         for(var j in data){
                var oTd = document.createElement("td");
                var txt = document.createTextNode(data[j]);
                oTd.appendChild(txt);
                oTr.appendChild(oTd);
         }

          oTable.appendChild(oTr);

    },
    createBtn:function (value,fun) {
        var oBtn = document.createElement("input");
        oBtn.type = "button";
        oBtn.value = value;
        oBtn.onclick = fun;
        return oBtn;
    },


}


